package org.example.auth.config;

import org.example.misc.config.BaseWebMvcConfigurer;
import org.example.misc.config.LogFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class BeanConfig {
    /**
     * 异常处理器
     * @return
     */
    @Bean
    public WebMvcConfigurer baseWebMvcConfigurer() {
        return new BaseWebMvcConfigurer();
    }

    /**
     * 记录 请求报文，过滤器
     * @return
     */
    @Bean
    FilterRegistrationBean<LogFilter> filterRegistrationBean() {
        FilterRegistrationBean<LogFilter> registration = new FilterRegistrationBean<>(new LogFilter());
        registration.addUrlPatterns("/*");
        registration.setOrder(Ordered.HIGHEST_PRECEDENCE);
        return registration;
    }
}
